//
//  QWLoggerFactory.m
//  WJLoggingAPI-example
//
//  Created by 吴云海 on 15-12-13.
//  Copyright (c) 2015年 WJ. All rights reserved.
//

#import "QWLoggerFactory.h"

@implementation QWLoggerFactory

static id<IQWLogger> logger = nil;

+(id<IQWLogger>) getLogger {
    if (!logger) {
        Class clazz = NSClassFromString(@"QWLogger");
        if (clazz) {
            if ([clazz conformsToProtocol:@protocol(IQWLogger)]) {
                logger = [[clazz alloc] init];
            } else {
                NSString *reason = [NSString stringWithFormat:@"无法创建Logger,因为 WJLogger 没有实现协议IQWLogger"];
                @throw [NSException exceptionWithName:@"QWLoggerFactoryException" reason:reason userInfo:@{@"QWLoggerClassName":@"QWLogger"}];
            }
        }
    }
    return logger;
}

@end